Skip to content

Fix LiftImperativeExpression prepend ordering#41

Draft
keyboardDrummer-bot wants to merge 1 commit intomainfrom
fix/lift-imperative-expression-39
Draft

Fix LiftImperativeExpression prepend ordering#41
keyboardDrummer-bot wants to merge 1 commit intomainfrom
fix/lift-imperative-expression-39

Conversation

@keyboardDrummer-bot
Copy link
Copy Markdown
Collaborator

Summary

Fixes the imperative call lifting in LiftImperativeExpressions.lean as described in #39.

Changes

When lifting an imperative call in expression position:

  1. Save previously accumulated prepended statements via takePrepends (these come from expressions processed earlier in right-to-left traversal, e.g., (x := 3) to the right of the call)
  2. Use the procedure's declared output type from SemanticModel when available (single output), falling back to computeType otherwise
  3. Place the lifted call before the saved prepends: liftedCall ++ previousPrependedStmts

Testing

Note

The uncommented test case doesn't pass yet because the call's arguments reference snapshot variables that are defined within previousPrependedStmts. A further fix is needed to split the prepends into arg-generated vs outer prepends. See the detailed analysis in the issue comment.

Fixes #39

…e calls

When lifting an imperative call in expression position, save the
previously accumulated prepended statements (from expressions processed
earlier in right-to-left traversal) and place them after the lifted call.
This ensures the call's declaration and assignment appear before the
side-effects of expressions that follow it in program order.

Also use the procedure's declared output type (from SemanticModel) when
available, falling back to computeType only for multi-output or unknown
cases.

Fixes #39
@keyboardDrummer-bot
Copy link
Copy Markdown
Collaborator Author

The "Run internal benchmarks of Strata" failure is an infrastructure issue, not a code issue. The benchmark CI job triggers an AWS CodeBuild build with --source-location-override https://github.com/strata-org/Strata.git, but this PR is on the keyboardDrummer/Strata fork — so CodeBuild can't find the commit SHA in the upstream repo.

I verified locally that:

  • The changed file (LiftImperativeExpressions.lean) builds successfully
  • All tests pass (lake test -- --exclude Languages.Python — the only failure is the pre-existing Java integration test that requires a downloaded jar)

This is the same issue noted in the main branch commit message: "Re-created from strata-org#1034 using an upstream branch so CI has access to required secrets." The benchmark job would need to be run from the upstream strata-org/Strata repo to succeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix bug in LiftImperativeExpression

2 participants